package com.hins.demo.model.transfer.valueobject;

import lombok.Value;

import java.math.BigDecimal;

/**
 * Description: 666
 *
 * @author wenjiaqi
 * @date 2021/5/14 19:08
 */
@Value
public class Money {
    BigDecimal amount;
    Currency currency;
    public Money(BigDecimal amount, Currency currency) {
        this.amount = amount;
        this.currency = currency;
    }

    public Money add(Money money) {
        return new Money(this.amount.add(money.getAmount()), this.currency);
    }

    public int compareTo(Money money) {
        return this.amount.compareTo(money.getAmount());
    }

    public Money subtract(Money money) {
        return new Money(this.amount.subtract(money.getAmount()), this.currency);
    }
}
